﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DeliveryOrderAdd.aspx.cs"
    Inherits="BySoft.Web.Site.OutSource.DeliveryOrderAdd" MasterPageFile="~/MastePage/SubEmptyMaster.Master" %>

<%@ MasterType VirtualPath="~/MastePage/SubEmptyMaster.Master" %>
<%@ Register Assembly="OneSoft.Web" Namespace="OneSoft.Web.UI.WebControls" TagPrefix="asp" %>
<%@ Register Src="../UserControl/SuggestTextBox2.ascx" TagName="SuggestTextBox2"
    TagPrefix="uc1" %>
<%@ Register Assembly="BySoft.Web.Controls" Namespace="BySoft.Web.Controls" TagPrefix="cc1" %>
<asp:Content ID="cphHeadContent" runat="server" ContentPlaceHolderID="EmptyMasteCPH">
    <script language="javascript" type="text/javascript">
        $(function () {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
        });

        function Refreashtab() {
            $("#tabs").tabs({ show: function (event, ui) { iframeAutoFit(); } });
        }


        //客户
        function FunCustomer() {
            ShowTopDialog('选择客户', '../ComPage/QuerySCustomerByOrder.aspx', 'FillFile();', 1000, 600); return false;
        }
        function FillFile() {
            var str = getCookie(dialogReturn_key);
            if (str != null && str != "") {
                str = decodeURIComponent(str);
                var strs = str.split(',');
                if (undefined != strs[0]) {
                    document.getElementById("<%=txtCustomerID.ClientID%>").value = strs[0];
                }
                if (undefined != strs[1]) {
                    document.getElementById("<%=txtCustomerName.ClientID%>").value = strs[1];
                }
                if (undefined != strs[3]) {
                    document.getElementById("<%=txtContactName.ClientID%>").value = strs[3];
                }
                if (undefined != strs[4]) {
                    document.getElementById("<%=txtMobile.ClientID%>").value = strs[4];
                }

            }
            setCookie(dialogReturn_key, "");
        }

        function OpenProductID() {
            var currentID = document.getElementById("<%=lblBillID.ClientID%>").value;
            var customerID = document.getElementById("<%=txtCustomerID.ClientID%>").value;


            //if (currentID == undefined) {
            //    alert("请选择客户");
            //    return;
            //}

            ShowTopDialog('产品选择', '../ComPage/QuerySProductByDeliveryOrder.aspx?id=' + currentID + '&customerId=' + customerID,
                'FillProductID();', 1000, 600); return false;
        }
        //回调
        function FillProductID() {

            var str = getCookie(dialogReturn_key);

            if (str != null && str != "") {

                $("#<%=btnAddh.ClientID %>").click();

            }
            setCookie(dialogReturn_key, "");

        }


        function ChangePriceAmount(obj) {

            var strBase = "txtPrice";
            var pre = obj.id.replace(strBase, "");

            var dtxtNum = $("#" + pre + "txtNums").val() * 1;                    //输入的数量
            var dtxtPrice = $("#" + pre + "txtPrice").val() * 1;                 //输入的价格

            var dAmount = 0;
            dAmount = dtxtPrice * dtxtNum;//金额 = 数量*单价


            // $("#" + pre + "txtPrice").val(dtxtPrice.toFixed(2));
            $("#" + pre + "txtAmount").val(dAmount.toFixed(2));

        }


    </script>

    <h1 class="tit">成品库存 >> <a href="DeliveryOrderList.aspx">成品出货单</a> >> 新增</h1>

    <div class="tableStyle2">
        <table cellpadding="0" cellspacing="0" id="tBase" runat="server">
            <tr>


                <th class="left2">表单号码：
                </th>
                <td class="right2">
                    <asp:Label CssClass="lblreadonly" ID="lblBillID" runat="server"></asp:Label>
                </td>
                <th class="left2">日期：
                </th>
                <td class="right2">
                    <asp:Label CssClass="lblreadonly" ID="lblBillDate" runat="server"></asp:Label>
                </td>

            </tr>
            <tr>
                <th class="left2">客户编号：
                </th>
                <td class="right2">
                     <asp:TextBox CssClass="lblreadonly" ID="txtCustomerID" runat="server"></asp:TextBox>
                    <span style="color: Red">*</span>
                    <asp:RequiredFieldValidator ControlToValidate="txtCustomerID" ID="rfvCustomer" Display="None" runat="server" ErrorMessage="请选择客户" ValidationGroup="gSubmit"></asp:RequiredFieldValidator>
                    <a style="cursor: pointer;" onclick="FunCustomer()">
                        <img src="../App_Themes/Common_CSS/images/dot_14.gif" alt="" /></a>
                </td>
                <th class="left2">客户名称：
                </th>
                <td class="right2">
                    <asp:TextBox ID="txtCustomerName" Enabled="false" CssClass="lblreadonly" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <th class="left2">联系人：</th>
                <td class="right2">
                    <asp:TextBox ID="txtContactName" runat="server" MaxLength="50" ReadOnly="true" CssClass="text ui-widget-content ui-corner-all"
                        Width="90%"></asp:TextBox>
                </td>
                <th class="left2">联系电话：</th>
                <td class="right2">
                    <asp:TextBox ID="txtMobile" runat="server" MaxLength="50" ReadOnly="true" CssClass="text ui-widget-content ui-corner-all"
                        Width="90%"></asp:TextBox>
                </td>
            </tr>

        </table>
    </div>



    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <div class="tableStyle">
                <div id="tabs">
                    <ul>
                        <li><a href="#tabs-1">明细</a></li>
                    </ul>
                    <div id="tabs-1" class="tableStyle">

                        <div style="text-align: right; width: 100%; padding-bottom: 10px">
                            <label class="btnStylec png_bg">
                                <input type="button" value="新增" onclick="OpenProductID()" />
                            </label>
                            <label class="btnStylec png_bg">
                                <asp:Button ID="btnAddh" runat="server" CssClass="Hidden" OnClick="btnAddh_Click" />
                            </label>
                        </div>
                        <div class="divscroll">
                            <asp:SGridView runat="server" ID="grdResult" Width="100%" ShowActionToolBar="false"
                                OnRowDataBound="grdResult_RowDataBound" OnRowCommand="grdResult_RowCommand" AutoGenerateColumns="false"
                                AllowCascade="false">
                                <Columns>
                                    <asp:TemplateField HeaderText="序号">
                                        <ItemTemplate>
                                            <%# Container.DisplayIndex+1 %>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField HeaderText="DetailID" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblDetailID" Text='<%#Eval("DetailID") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                       <asp:TemplateField HeaderText="Price" ItemStyle-CssClass="Hidden" FooterStyle-CssClass="Hidden" HeaderStyle-CssClass="Hidden">
                                        <ItemTemplate>
                                            <asp:Label ID="lblPrice" Text='<%#Eval("Price") %>' runat="server"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            产品编号
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblProductID" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>


                                    <asp:TemplateField>
                                        <HeaderTemplate>品名</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lblProductName" runat="server" Text='<%#  Eval("ProductName") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>规格</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtSpecifications" runat="server" Text='<%#  Eval("Specifications") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>单位</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtUnit" runat="server" Text='<%#  Eval("Unit") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>客户零件号</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtCustomerPartNo" runat="server" Text='<%#  Eval("CustomerPartNo") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <HeaderTemplate>外径</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtOutSide" runat="server" Text='<%#  Eval("OutSide") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <HeaderTemplate>内径</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtInSide" runat="server" Text='<%#  Eval("InSide") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>未出货数量</HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="txtLastNum" runat="server" Text='<%#  Eval("LastNum") %>'></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>

                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            数量
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:TextBox ID="txtNums" runat="server" Text='<%#Eval("Nums") %>'></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="rfvNums" runat="server" ErrorMessage="请输入数量！"
                                                ControlToValidate="txtNums" Display="None" ValidationGroup="gSubmit" />

                                            <asp:RegularExpressionValidator ControlToValidate="txtNums" Display="None"
                                                ErrorMessage="数量输入有误，请重新输入！" ID="revNums"
                                                ValidationExpression="\d*(\.\d*)?" ValidationGroup="gSubmit" runat="server" />

                                        </ItemTemplate>
                                    </asp:TemplateField>



                                    <asp:TemplateField>
                                        <HeaderStyle Width="35px" />
                                        <ItemStyle Width="35px" />
                                        <HeaderTemplate>
                                            删除
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:ImageButton ImageUrl="~/App_Themes/Common_CSS/images/delete_small.gif" runat="server"
                                                ID="ibtnDel" /><asp:Button ID="btnDel" runat="server" CssClass="Hidden" CommandArgument='<%# Container.DisplayIndex %>'
                                                    CommandName="del" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                            </asp:SGridView>
                        </div>


                    </div>
                </div>
            </div>
        </ContentTemplate>
    </asp:UpdatePanel>


    <div class="controlBar" align="center">
        <table cellpadding="0" cellspacing="0" style="width: 300px; margin: 0 auto;">
            <tr>
                <td colspan="4">
                    <label class="btnStyleb png_bg">
                        <asp:Button ID="btnSubmit" runat="server" Text="确定"
                            OnClick="btnSubmit_Click" ValidationGroup="gSubmit" />
                    </label>
                    <label class="btnStylec png_bg">
                        <input type="button" id="Button2" value="返回" runat="server" onclick="window.location = 'ProductInStockList.aspx'" />
                    </label>
                </td>
            </tr>
        </table>
    </div>

</asp:Content>


